import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @Author: Take-off
 * @Description: //TODO 简单的 Bean 工厂
 * @Date: 3:31 PM 2022/12/10
 **/
public class BeanFactory {
    //ConcurrentHashMap 就是线程安全 的 HashMap
    private Map<String, BeanDefinition> beanDefinitionMap = new ConcurrentHashMap<>();
    //通过名字获取
    public Object getBean(String name) {
        return beanDefinitionMap.get(name).getBean();
    }
    //注册
    public void registerBeanDefinition(String name, BeanDefinition beanDefinition) {
        beanDefinitionMap.put(name, beanDefinition);
    }
}
